<?php
/**********************************************************************************
* SM-TestSuite.template.php                                                       *
***********************************************************************************
* Project Name: Test Suite                                                        *
* Written by: Joker™                                                              *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines NPO.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
***********************************************************************************
* Copyright 2011 SimpleMachines NPO - All Rights Reserved                         *
**********************************************************************************/

function template_main()
{
        global $context, $scripturl, $settings, $txt;

        // Start our template...
        echo ' 
        <div class="cat_bar">
                        <h3 class="catbg">', $txt['sm_testsuite'], '</h3>
        </div>
        <div class="information">', $txt['sm_testsuite_desc'], '</div>';

        // Shout a button calling people to create projects :P
        echo '
        <div class="buttons">
                <ul>
                        <li><a class ="active" href="', $scripturl, '?action=createproject"><span>', $txt['create_project'], '</span></a></li>
                </ul>
        </div><br /><br />';
        
        // Show info of the projects created so far
        echo '
        <div class="suite_frame">';
        foreach ($context['test_suite']['project'] as $key => $value)
        {
                echo '
                <div class="header"><strong>', $txt['project_name'], '</strong>', ' - ', $value['link'], '<div class="floatright">
                        <a class ="active" href="', $scripturl, '?action=editproject;project=', $value['id'], '">
                                        <img src="' . $settings['images_url'] . '/buttons/blue-folder--pencil.png" alt="', $txt['edit'], ' ', $txt['project'], '" title="', $txt['edit'], ' ', $txt['project'], '" />
                        </a>
                </div>
        </div>';
        echo '
        <div class="text_style"><strong>', $txt['project_description'], '</strong>', ' - ', $value['description'], '</div>';
                if(!empty($value['modified_by']))
                        echo '<div class="text_style modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</div>';
                echo '
                <hr class="clear" />';
        }
        echo '
        </div>';
}

function template_sm_testsuite_project_view()
{
        global $txt, $scripturl, $suite, $context, $settings;
        
        // Start our template...
        echo '
                <div class="cat_bar">   
                        <h3 class="catbg">', $context['test_suite']['current_project']['link'], '</h3>
                </div>
                <div class="information">', $context['test_suite']['current_project']['description'], '</div>';

        // Shout a button calling people to create suites :P
        echo '
                <div class="buttons">
                        <ul>
                                <li><a class ="active" href="', $scripturl, '?action=createproject;project=' . $context['test_suite']['current_project']['id'] .'""><span>', $txt['create_suite'], '</span></a></li>
                        </ul>
                </div><br /><br />';
                
        // Show info of the suites created so far
        if (isset($context['test_suite']['suite']))
        {
                echo '
                <div class="suite_frame">';
                foreach ($context['test_suite']['suite'] as $key => $value)
                {
                        echo '
                        <div class="header"><strong>', $txt['suite_name'], '</strong>', ' - ', $value['link'], '
                                <div class="floatright">
                                        <a class ="active" href="', $scripturl, '?action=editproject;project='. $value['id_project'] . ';suite='. $value['id'] . '">
                                                <img src="' . $settings['images_url'] . '/buttons/blue-folder--pencil.png" alt="', $txt['edit'], ' ', $txt['suite'], '" title="', $txt['edit'], ' ', $txt['suite'], '" />
                                        </a>
                                </div>
                        </div>';
                        echo '
                        <div class="text_style">
                                <strong>', $txt['suite_description'], '</strong>
                                ', ' &#045; ', $value['description'], '
                        </div>';

                        if (empty($value['count']))
                                echo '
                        <div class="text_style">
                                <strong>', $txt['total_run_count'], '</strong>
                                ', ' &#045; ', $value['count'], '
                        </div>';
                        else
                                echo '
                                <div class="text_style">
                                        <strong>', $txt['total_run_count'], '</strong>
                                        ', ' &#045; ', $value['count_link'], '
                                </div>';

                        if (empty($value['pass_count']))
                                echo '
                                <div class="text_style">
                                        <strong>', $txt['pass_count'], '</strong>
                                        ', ' &#045; ', $value['pass_count'], '
                                </div>';
                        else
                                echo '
                                <div class="text_style">
                                        <strong>', $txt['pass_count'], '</strong>
                                        ', ' &#045; ', $value['pass_count_link'], '
                                </div>';

                        if (empty($value['fail_count']))
                                echo '
                                <div class="text_style">
                                        <strong>', $txt['fail_count'], '</strong>
                                        ', ' &#045; ', $value['fail_count'], '
                                </div>';
                        else
                                echo '
                                <div class="text_style">
                                        <strong>', $txt['fail_count'], '</strong>', 
                                        ' &#045; ', $value['fail_count_link'], '
                                        </div>';

                if (!empty($value['modified_by']))
                echo '
                <div class="text_style modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</div>';
                        echo '
                        <hr class="clear" />';
                }
                
        echo '
                </div>';
        }
}

function template_sm_testsuite_case_view()
{

        global $txt, $scripturl, $context, $settings;
        
        // Start our template...
        echo '
                <div class="cat_bar">   
                        <h3 class="catbg">', $context['test_suite']['current_suite']['link'], '</h3>
                </div>
                <div class="information">', $context['test_suite']['current_suite']['description'], '</div>';

        // Shout a button calling people to create test cases :P
        echo '
                <div class="buttons">
                        <ul>
                                <li><a class ="active" href="', $scripturl, '?action=createcase;project=' . $context['test_suite']['current_project']['id'] .';suite=' . $context['test_suite']['current_suite']['id'] .'"><span>', $txt['create_case'], '</span></a></li>
                        </ul>
                </div><br /><br />';
                
        // Show info of the test cases created so far
        if (isset($context['test_suite']['case']))
        {
                echo '
                        <div class="suite_frame">';
                        
                        foreach ($context['test_suite']['case'] as $key => $value)
                        {
                                echo '
                                <div class="header"><strong>', $txt['case_name'], '</strong>', ' - ', $value['link'], '
                                        <div class="floatright">
                                        <a class ="active" href="', $scripturl, '?action=editcase;project='. $context['test_suite']['current_project']['id'] . ';suite='. $value['id_suite'] . ';case='. $value['id'] . '">
                                                <img src="' . $settings['images_url'] . '/buttons/blue-folder--pencil.png" alt="', $txt['edit'], ' ', $txt['case'], '" title="', $txt['edit'], ' ', $txt['case'], '" />
                                        </a>
                                </div>
                        </div>';
                                echo '
                                <div class="text_style"><strong>', $txt['case_description'], '</strong>', ' - ', $value['description'], '</div>';
                                echo '
                                <div class="text_style"><strong>', $txt['total_run_count'], '</strong>', ' - ', $value['count'], '</div>';
                                echo '
                                <div class="text_style"><strong>', $txt['pass_count'], '</strong>', ' - ', $value['pass_count'], '</div>';
                                echo '
                                <div class="text_style"><strong>', $txt['fail_count'], '</strong>', ' - ', $value['fail_count'], '</div>';
                                if(!empty($value['modified_by']))
                                        echo '
                                <div class="text_style modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</div>';
                                echo '
                                <hr class="clear" />';
                        }
                        
                echo '
                        </div>';
        }
}

function template_sm_testsuite_separate_case_view()
{

        global $txt, $scripturl, $context, $run, $settings;
        
        // Start our template...
        echo '<div class="suite_frame">';
        
        // Time to get boxes in palces :P, div power. Show all infomation regarding to this specific test case
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $txt['case_details'], '</h3>
                </div>';
        
        echo '
                <div class="details">
                        <strong>', $txt['project_id'], '</strong>',
                        ' &#045; ', $context['test_suite']['current_project']['id'], '
                </div>';
                
        echo '
                <div class="details">
                        <strong>', $txt['suite_id'], '</strong>', 
                        ' &#045; ', $context['test_suite']['current_suite']['id'], '
                </div>';
                
        echo '
                <div class="details">
                        <strong>', $txt['case_id'], '</strong>',
                        ' &#045; ', $context['test_suite']['current_case']['id'], '
                </div>';
        
        
        if(!empty($context['test_suite']['current_case']['id_assigned']))
        echo '
                <div class="details">
                        <strong>', $txt['assigned_to'], ': ' , '</strong>',
                                $context['test_suite']['current_case']['id_assigned'], '
                </div>';
        
        echo '
                <hr class="clear" /><br />';
        
        echo '
                <div class="details">
                        <strong>', $txt['case_name'], '</strong>', 
                        ' &#045; ',  $context['test_suite']['current_case']['name'], '
                </div>
                <hr class="clear" /><br />';
        
        echo '
                <div class="details">
                        <strong>', $txt['description'], '</strong>
                </div><br /><br />';
                
        echo '
                <div class="suite_frame_right">',  $context['test_suite']['current_case']['description'], '</div>
                <br /><br /><hr class="clear" /><br />';
        
        echo '
                <div class="details">
                        <strong>', $txt['steps'], '</strong>
                </div><br /><br />';
        
        echo '
                <div class="suite_frame_right">',  $context['test_suite']['current_case']['steps'], '</div>
                <br /><br /><hr class="clear" /><br />';
        
        if(!empty($context['test_suite']['current_case']['expected_result']))
        {
        echo '
                <div class="details">
                        <strong>', $txt['expected_result'], '</strong>
                </div><br /><br />';
        
        echo '
                <div class="suite_frame_right">',  $context['test_suite']['current_case']['expected_result'], '</div>
                <br /><br /><hr class="clear" /><br />';
        }

        echo '
                </div>';
        
        // Shout a button calling people to submit there run results :P
        echo '
                <div class="buttons">
                        <ul>
                                <br /><li>
                                        <a class ="active" href="', $scripturl, '?action=editcase;project=' . $context['test_suite']['current_project']['id'] .';suite=' . $context['test_suite']['current_suite']['id'] .';case=' . $context['test_suite']['current_case']['id'] .'">
                                                <span>', $txt['edit_case'], '</span>
                                        </a>
                                </li><br /><br />
                                <li>
                                        <a class ="active" href="', $scripturl, '?action=createrun;project=' . $context['test_suite']['current_project']['id'] .';suite=' . $context['test_suite']['current_suite']['id'] .';case=' . $context['test_suite']['current_case']['id'] .'">
                                                <span>', $txt['submit_run_result'], '</span>
                                        </a>
                                </li>
                        </ul>
                </div><br /><br />';
        
        // Show info of the run feedback regarding to this test case
        if (isset($context['test_suite']['run']))
        {
                echo '
                        <div class="suite_frame">';
                        
                        foreach ($context['test_suite']['run'] as $key => $value)
                        {
                                echo '
                                        <div class="header">
                                                <strong>', $txt['ran_by'], '</strong>', ' - ', $value['member']['link'], '
                                                <div class="floatright">', $value['time'], '
                                                        <a class ="active" href="', $scripturl, '?action=editrun;project='. $context['test_suite']['current_project']['id'] . ';suite='. $context['test_suite']['current_suite']['id'] . ';case='. $value['id_case'] . ';run='. $value['id'] . '">
                                                                <img src="' . $settings['images_url'] . '/buttons/blue-folder--pencil.png" alt="', $txt['edit'], ' ', $txt['run'], '" title="', $txt['edit'], ' ', $txt['run'], '" />
                                                        </a>
                                        </div>
                        </div>';
                        
								echo '
								<a id="run', $value['id'], '"></a>';
								
								echo '
										<div class="', $value['result_achieved'] == 'fail' ? 'text_style red' : 'text_style','">
												<strong>', $txt['run_id'], '</strong>', ' - ', '
												<a style="', $value['result_achieved'] == 'fail' ? 'color:#ff0000;' : '','" href="', $value['href'], '">', $value['id'], '</a>
										</div>';
								echo '
										<div class="', $value['result_achieved'] == 'fail' ? 'text_style red' : 'text_style','">
												<strong>', $txt['run_result'], '</strong>', ' - ', $value['result_achieved'], '
										</div>';
                                
                                echo '
                                        <div class="text_style">
                                                <strong>', $txt['feedback'], '</strong>', ' - ', $value['feedback'], '
                                        </div>';

                                if($value['id_bug'] != 0)
                                echo '
                                        <div class="text_style">
                                                <strong>', $txt['id_bug'], '</strong>', ' - ', $value['id_bug'], '
                                        </div>';
                                if(!empty($value['modified_by']))
                                echo '<div class="text_style modified">', 'Last edited by', ' ', $value['modified_by'], ' ', $txt['at'], ' ', $value['modified_time'], '</div>';

                                echo '<hr class="clear" />';
                        }
                echo '
                        </div>';
        }
}

function template_sm_testsuite_count_link()
{
        global $txt, $scripturl, $context;
        
		$result = isset($_REQUEST['result']) ? strtolower($_REQUEST['result']) : '';
        
        // Start our template...
        echo '
                <div class="cat_bar">   
                        <h3 class="catbg">', $context['test_suite']['current_suite']['link'], '</h3>
                </div>
                <div class="information">', $context['test_suite']['current_suite']['description'], '</div>';
        // Show info of the test cases created so far
        echo'
                <div class="suite_frame">';
                        
                        if ($result == 'fail' || $result == 'pass')
                        foreach ($context['test_suite']['run_links'] as $key => $value)
                        {
                                echo '<div class="text_style"><strong>', $txt['case_id'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['id_case'], '</a></div>';
                                echo '<div class="text_style"><strong>', $txt['case_name'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['case_name'], '</a></div>';
                                echo '<div class="text_style"><strong>', $txt['run_id'], '</strong>', ' - ', $value['link'], '</div>';
                                echo '<hr class="clear" />';
                        }
                        
                        else
                        foreach ($context['test_suite']['total_run_links'] as $key => $value)
                        {
                                echo '<div class="text_style"><strong>', $txt['case_id'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['id_case'], '</a></div>';
                                echo '<div class="text_style"><strong>', $txt['case_name'], '</strong>', ' - ', '<a href="', $value['href'], '">', $value['case_name'], '</a></div>';
                                echo '<div class="text_style"><strong>', $txt['run_id'], '</strong>', ' - ', $value['link'], '</div>';
                                echo '<hr class="clear" />';
                        }

        echo '
                </div>';
}

// Let make some creative(ohh creation functions :P).
function template_create_project()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=createproject2;" method="post">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';
                                
        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['description']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_project']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_suite']), '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['description']) ? '' : implode('<br />', $context['post_error']['description']), '
                                </dt>
                        </dl>
                </div>';

        // The post header... important stuff
        echo '
                <dl id="post_header">';

        // Show a box so that user can write the Project/Suite name
        echo '
                <dt>
                        <label for="name">
                                <span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_subject">', $txt['name'], ':</span>
                        </label>
                </dt>
                <dd>
                        <input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
                </dd>';
                                                
        echo'
                </dl><hr class="clear" />';

        // Write description related to Project/Suite
        echo '
                <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="description">', $txt['description'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="description" id="description" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_description']) || isset($context['post_error']['long_description']) ? 'border: 1px solid red;' : '', '">', isset($context['description']) ? $context['description'] : '', '</textarea>
                </div>';
        
        // Ohh take the Project ID if we using this function for creation of suites
        echo'
                <input type="hidden" name="project" value="', $context['test_suite']['current_project'] , '" />';

        // Finally, the submit button.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

// Just to make things less complicated one more function for level 3 & 4
function template_create_case()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=createcase2;" method="post">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';

        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['message']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', $txt['error_while_creating_case'], '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['message']) ? '' : implode('<br />', $context['post_error']['message']), '
                                </dt>
                        </dl>
                </div>';

        // The post header... important stuff
        echo '
                <dl id="post_header">';

        // Show a box so that user can write the Test Cases name
        echo '
        <dt>
                <label for="name">
                        <span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_name">', $txt['name'], ':</span>
                </label>
        </dt>
        <dd>
                <input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
        </dd>';

        echo'
                </dl><hr class="clear" />';

        // Write description related to Test Cases
        echo'
                <div id="description">
                        <div class="description_text">';
                        
        echo '
                <br /><br /><br /><br />', $txt['description'];
        
        echo '
                </div>
                <div class="description_box">';
        
        // Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
        if ($context['show_bbc'])
        {
                echo '
                        <div id="bbcBox_message"></div>';
        }

        // What about smileys?
        if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
                echo '
                        <div id="smileyBox_message"></div>';
        
        // Atlast show the box to type description
        echo '
                ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); 
                                
        echo '
                </div>
                </div><hr class="clear" /><br /><br />';

        // We need a box to type steps also
        echo '
                <div>
                        <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="steps">', $txt['steps'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="steps" id="steps" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_steps']) || isset($context['post_error']['long_steps']) ? 'border: 1px solid red;' : '', '">', isset($context['steps']) ? $context['steps'] : '', '</textarea>
                        </div>
                </div><hr class="clear" /><br />';
                
                /*
                                        <textarea class="editor" name="steps" id="steps" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['test_suite']['post_error']['no_steps']) || isset($context['test_suite']['post_error']['long_steps']) ? 'border: 1px solid red;' : '', '">', isset($context['test_suite']['steps']) ? $context['test_suite']['steps'] : '', '</textarea>
                */

        // Now show the expected result box for this post.
        echo '
                <dl id="post_header">
                        <dt>
                                <label for="expected_result">
                                        <span', isset($context['post_error']['expected_result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['expected_result'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="expected_result" id="expected_result"', isset($context['expected_result']) ? ' value="' . $context['expected_result'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="150" maxlength="255" class="input_text" />
                        </dd>
                </dl><hr class="clear" />';
                
        // So who's the champ to which this Case is going to be allotted
        echo '
                <dl id="post_header">
                        <dt>
                                <label for="id_assigned">
                                        <span', isset($context['post_error']['id_assigned']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_assigned'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="id_assigned" id="id_assigned"', isset($context['id_assigned']) ? ' value="' . $context['id_assigned'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
                        </dd>
                </dl><hr class="clear" />';
        
        //Request the id's of Project, Suite and Test Case on our way to exit
                echo'
                        <input type="hidden" name="project" value="', $context['test_suite']['current_project'], '" />
                        <input type="hidden" name="suite" value="', $context['test_suite']['current_suite'], '" />';

        // Finally, the submit buttons.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

function template_create_run()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=createrun2;" method="post" enctype="multipart/form-data">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';

        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['feedback']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_run']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_run']), '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['feedback']) ? '' : implode('<br />', $context['post_error']['feedback']), '
                                </dt>
                        </dl>
                </div>';
                
       // The post header... important stuff
        echo '
                <dl id="post_header">';

        // So what's the result of the run?
        echo '
                <dt>
                        <label for="result">
                                <span', isset($context['post_error']['result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['result'], ':</span>
                        </label>
                </dt>
                <dd>
					<select name="result" tabindex="', $context['tabindex']++, '">
						<option value="select" selected="selected">', '(', $txt['select'], ')', '</option>
						<option value="pass"', (isset($context['result_achieved']) && ($context['result_achieved'] == 'pass')) ? ' selected="selected"' : '', '>', $txt['pass'], '</option>
						<option value="fail"', (isset($context['result_achieved']) && ($context['result_achieved'] == 'fail')) ? ' selected="selected"' : '', '>', $txt['fail'], '</option>
					</select>
                </dd>';
                
        echo'
                </dl><hr class="clear" />';

        // Ask user aout the feedback of the run he/she has made
        echo '
                <div>
                        <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="feedback">', $txt['feedback'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="feedback" id="feedback" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_feedback']) || isset($context['post_error']['long_feedback']) ? 'border: 1px solid red;' : '', '">', isset($context['feedback']) ? $context['feedback'] : '', '</textarea>
                        </div>
                </div>';
                
        // Ask the bug ID, pitty we are asking users to submit this manually at this stage :(
        echo '
                <hr class="clear" />
                <dl id="post_header">
                        <dt>
                                <label for="id_bug">
                                        <span', isset($context['post_error']['id_bug']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_bug'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="id_bug" id="id_bug"', isset($context['id_bug']) ? ' value="' . $context['id_bug'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
                        </dd>
                </dl>';

                //Request the id's of Project, Suite and Test Case on our way to exit
                echo'
                        <input type="hidden" name="project" value="', $context['test_suite']['current_project'], '" />
                        <input type="hidden" name="suite" value="', $context['test_suite']['current_suite'], '" />
                        <input type="hidden" name="case" value="', $context['test_suite']['current_case'], '" />';

        // Finally, the submit buttons.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

function template_edit_project()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=editproject2;" method="post" enctype="multipart/form-data">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';
                                
        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['description']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_project']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_suite']), '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['description']) ? '' : implode('<br />', $context['post_error']['description']), '
                                </dt>
                        </dl>
                </div>';

		// The post header... important stuff
        echo '
                <dl id="post_header">';

        // Show a box so that user can write the Project/Suite name
        echo '
                        <dt>
                                <label for="name">
                                        <span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_subject">', $txt['name'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
                        </dd>';
                                                
        echo'
                </dl>
                <hr class="clear" />';

        // Write description related to Project/Suite
        echo '
                <div>
                        <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="description">', $txt['description'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="description" id="description" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_description']) || isset($context['post_error']['long_description']) ? 'border: 1px solid red;' : '', '">', isset($context['description']) ? $context['description'] : '', '</textarea>
                        </div>
                </div>';
        
        // Ohh take the Project ID if we're using this function for creation of suites
        echo'
                <input type="hidden" name="project" value="', $context['test_suite']['current_project'], '" />
                <input type="hidden" name="suite" value="', $context['test_suite']['current_suite'], '" />';
                
        // Finally, the submit button.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

// Just to make things less complicated one more function for level 3 & 4
function template_edit_case()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=editcase2;" method="post">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';

        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['message']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', $txt['error_while_creating_case'], '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['message']) ? '' : implode('<br />', $context['post_error']['message']), '
                                </dt>
                        </dl>
                </div>';

        // The post header... important stuff
        echo '
                <dl id="post_header">';

        // Show a box so that user can write the Test Cases name
        echo '
        <dt>
                <label for="name">
                        <span', isset($context['post_error']['name']) ? ' class="error"' : '', ' id="caption_name">', $txt['name'], ':</span>
                </label>
        </dt>
        <dd>
                <input type="text" name="name" id="name"', isset($context['name']) ? ' value="' . $context['name'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
        </dd>';

        echo'
                </dl><hr class="clear" />';

        // Write description related to Test Cases
        echo'
                <div id="description">
                        <div class="description_text">';
                        
        echo '
                <br /><br /><br /><br />', $txt['description'];
        
        echo '
                </div>
                <div class="description_box">';
        
        // Show the actual posting area (woohh BBC codes usage, never going to forget this part :()
        if ($context['show_bbc'])
        {
                echo '
                        <div id="bbcBox_message"></div>';
        }

        // What about smileys?
        if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
                echo '
                        <div id="smileyBox_message"></div>';
        
        // Atlast show the box to type description
        echo '
                ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); 
                                
        echo '
                </div>
                </div><hr class="clear" /><br /><br />';

        // We need a box to type steps also
        echo '
                <div>
                        <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="steps">', $txt['steps'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="steps" id="steps" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_steps']) || isset($context['post_error']['long_steps']) ? 'border: 1px solid red;' : '', '">', isset($context['steps']) ? $context['steps'] : '', '</textarea>
                        </div>
                </div><hr class="clear" /><br />';

        // Now show the expected result box for this post.
        echo '
                <dl id="post_header">
                        <dt>
                                <label for="expected_result">
                                        <span', isset($context['post_error']['expected_result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['expected_result'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="expected_result" id="expected_result"', isset($context['expected_result']) ? ' value="' . $context['expected_result'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="150" maxlength="255" class="input_text" />
                        </dd>
                </dl><hr class="clear" />';
                
        // So who's the champ to which this Case is going to be allotted
        echo '
                <dl id="post_header">
                        <dt>
                                <label for="id_assigned">
                                        <span', isset($context['post_error']['id_assigned']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_assigned'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="id_assigned" id="id_assigned"', isset($context['id_assigned']) ? ' value="' . $context['id_assigned'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
                        </dd>
                </dl><hr class="clear" />';
        
                //Request the id's of Project, Suite and Test Case on our way to exit
                echo'
                        <input type="hidden" name="project" value="', $context['test_suite']['current_project'], '" />
                        <input type="hidden" name="suite" value="', $context['test_suite']['current_suite'], '" />
                        <input type="hidden" name="case" value="', $context['test_suite']['current_case'], '" />';

		// Finally, the submit buttons.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

function template_edit_run()
{
        global $context, $txt, $scripturl;

        echo '
                <form action="', $scripturl, '?action=editrun2;" method="post" enctype="multipart/form-data">';

        // Start the main table.
        echo '
                <div class="cat_bar">
                        <h3 class="catbg">', $context['page_title'], '</h3>
                </div>
                <div>
                        <span class="upperframe"><span></span></span>
                        <div class="roundframe">';

        // If an error occurred, explain what happened.
        echo '
                <div class="errorbox"', empty($context['post_error']['feedback']) ? ' style="display: none"' : '', ' id="errors">
                        <dl>
                                <dt>
                                        <strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', (empty($context['test_suite']['current_run']) ? $txt['error_while_creating_project'] : $txt['error_while_creating_run']), '</strong>
                                </dt>
                                <dt class="error" id="error_list">
                                        ', empty($context['post_error']['feedback']) ? '' : implode('<br />', $context['post_error']['feedback']), '
                                </dt>
                        </dl>
                </div>';

        // The post header... important stuff
        echo '
                <dl id="post_header">';

        // So what's the result of the run?
        echo '
                <dt>
                        <label for="result">
                                <span', isset($context['post_error']['result']) ? ' class="error"' : '', ' id="caption_subject">', $txt['result'], ':</span>
                        </label>
                </dt>
                <dd>
					<select name="result" tabindex="', $context['tabindex']++, '">
						<option value="select" selected="selected">', '(', $txt['select'], ')', '</option>
						<option value="pass"', 'pass' == $context['result_achieved'] ? ' selected="selected"' : '', '>', $txt['pass'], '</option>
						<option value="fail"', 'fail' == $context['result_achieved'] ? ' selected="selected"' : '', '>', $txt['fail'], '</option>
					</select>
                </dd>';
                
        echo'
                </dl><hr class="clear" />';

        // Ask user aout the feedback of the run he/she has made
        echo '
                <div>
                        <div class="textbox">
                                <div class="text">
                                        <p>
                                                <label for="feedback">', $txt['feedback'], ':</label>
                                        </p>
                                </div>
                                        <textarea class="editor" name="feedback" id="feedback" rows="20" cols="600" tabindex="', $context['tabindex']++, '" style="width: 70%; height: 150px; ', isset($context['post_error']['no_feedback']) || isset($context['post_error']['long_feedback']) ? 'border: 1px solid red;' : '', '">', isset($context['feedback']) ? $context['feedback'] : '', '</textarea>
                        </div>
                </div>';
                
        // Ask the bug ID, pitty we are asking users to submit this manually at this stage :(
        echo '
                <hr class="clear" />
                <dl id="post_header">
                        <dt>
                                <label for="id_bug">
                                        <span', isset($context['post_error']['id_bug']) ? ' class="error"' : '', ' id="caption_subject">', $txt['id_bug'], ':</span>
                                </label>
                        </dt>
                        <dd>
                                <input type="text" name="id_bug" id="id_bug"', isset($context['id_bug']) ? ' value="' . $context['id_bug'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="10" maxlength="10" class="input_text" />
                        </dd>
                </dl>';
                
                //Request the id's of Project, Suite and Test Case on our way to exit
                echo'
                        <input type="hidden" name="project" value="', $context['test_suite']['current_project'], '" />
                        <input type="hidden" name="suite" value="', $context['test_suite']['current_suite'], '" />
                        <input type="hidden" name="case" value="', $context['test_suite']['current_case'], '" />
                        <input type="hidden" name="run" value="', $context['test_suite']['current_run'], '" />';
                        
        // Finally, the submit buttons.
        echo '
                <br />
                <p class="righttext">
                        <input type="submit" value="', $txt['post'], '" tabindex="', $context['tabindex']++, '" class="button_submit" />
                </p>
                        </div>
                        <span class="lowerframe"><span></span></span>
                </div>
                <br class="clear" />
        </form>';
}

?>